package com.qhg.saas_server.controller;

import com.github.pagehelper.PageInfo;
import com.qhg.saas_server.pojo.Comployee;
import com.qhg.saas_server.pojo.dto.ProcureListDto;
import com.qhg.saas_server.service.ProcureService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/procure")
@Slf4j
public class ProcureController {
    @Autowired
    ProcureService procureService;
    //获取采购列表
    @GetMapping("/list")
    public PageInfo list(){
        return procureService.findAll();
    }
    //审批
    @GetMapping("/examine")
    public int examine (Integer listId,Integer statusId,String listApprove){
        return procureService.examine(listId,statusId,listApprove);
    }
    //删除采购
    @GetMapping("/delete")
    public int delete(Integer listId){
        return procureService.deleteProcure(listId);
    }
    //添加采购
    @PostMapping("/add")
    public int add (@RequestBody ProcureListDto procureListDto){
        return procureService.addProcure(procureListDto);
    }

    //条件查询
    @GetMapping("/select")
    public PageInfo select (String beforeTime, String afterTime, String supName, String statusDescription){
        return procureService.selectProcureByCondition(beforeTime, afterTime, supName, statusDescription);
    }
    //查询采购详情


    /**
     * 三表联查
     * @param listId
     * @return
     */
    @GetMapping("/selectProcure")
    public ProcureListDto selectProcure(Integer listId){
        return procureService.selectById(listId);
    }
    //修改采购信息
    @PostMapping("/updateProcure")
    public int updateProcure(@RequestBody ProcureListDto procureListDto){
        return procureService.updateProcure(procureListDto);
    }
    @GetMapping("/listComp")
    public List<Comployee> listComp(){
        return procureService.listComp();
    }
}
